<template>
  <div class="stubro">
    <h2>2021招生简章</h2>
<!--    <div class="item"-->
<!--         v-for="(item,index) in tableData" :key="index+1">-->
    <div class="container">
    <el-table
      v-loading="loading"
      :data="tableData"
      border
      style="width: 100%">
      <el-table-column
        prop="stid"
        label="序号"
        width="180">
      </el-table-column>
      <el-table-column
        prop="stname"
        label="学校"
        width="180">
      </el-table-column>
      <el-table-column
        prop="sttype"
        label="学校">
      </el-table-column>

<!--      <el-table-column-->
<!--        fixed="right"-->
<!--        label="操作2"-->
<!--        width="100">-->
<!--        <template slot-scope="scope">-->
<!--          <el-button @click="handleClick(item.stinfo)" type="text" size="small">查看</el-button>-->
<!--        </template>-->
<!--      </el-table-column>-->

      <el-table-column label="操作" prop="stinfo">
        <template slot-scope="scope">
          <el-button
            size="mini"
            @click="dialogVisible = true">查看信息</el-button>

          <el-dialog
            title="提示"
            :visible.sync="dialogVisible"
            width="80%"
            :before-close="handleClose">
            <span>{{stinfo}}</span>
            <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
          </el-dialog>
          </template>
      </el-table-column>


    </el-table>
    <div style="margin:0 auto;padding-top: 20px;width: 80%">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[5, 10, 20]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
<!--  </div>-->
  </div>
</template>

<script>
import request from '../utils/request'
export default {
  data () {
    return {
      loading: true,
      tableData: [],
      currentPage: 1,
      pageSize: 10,
      total: 0,
      dialogVisible: false

    }
  },
  created () {
    this.load()
  },
  methods: {
    load () {
      this.loading = true
      request.get('api/stubro', {
        params: {
          pageNum: this.currentPage,
          pageSize: this.pageSize
        }
      }).then(res => {
        this.loading = false
        this.tableData = res.data.records
        this.stinfo = res.data.records[3].stinfo
        this.total = res.data.total
        console.log(res.data.records)
        console.log(res.data.records.stinfo)
        console.log(this.stinfo)
      })
    },
    handleCurrentChange (pageNum) {
      this.currentPage = pageNum
      this.load()
    },
    handleSizeChange (pageSize) {
      this.pageSize = pageSize
      this.load()
    },
    handleClose (done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done()
        })
        .catch(_ => {})
    }
    // handleClick (row) {
    //   console.log(row)
    // }
  }
}
</script>
<style lang="scss" scoped>
.stubro{
  h2{
    padding-top: 20px;
    font-size: 50px;
    font-weight: 200;
    line-height: 50px;
    margin-left: 160px;
    color: #333;
  }
  .container{
    padding-top: 40px;
    margin-left: 140px;
  }
}
</style>
